package com.xiaokaceng.openci.domain;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

import com.xiaokaceng.openci.CasUserManageNotConfigException;

import java.util.List;

@Entity
@DiscriminatorValue("CAS_USER_MANAGE")
public class CasUserConfiguration extends ToolConfiguration {

	private static final long serialVersionUID = 273891251627741059L;

	public CasUserConfiguration() {
		super();
	}

    @Override
    public String[] businessKeys() {
        return new String[]{"name"};
    }

    public CasUserConfiguration(String name, String serviceUrl, String username, String password) {
		super(name, serviceUrl, username, password);
	}

	public static CasUserConfiguration getUniqueInstance() {
		List<CasUserConfiguration> casUserConfigurations = CasUserConfiguration.findAll(CasUserConfiguration.class);
		if (casUserConfigurations.isEmpty()) {
			throw new CasUserManageNotConfigException();
		}
		return casUserConfigurations.get(0);
	}

	@Override
	public String getRequestAddress(String projectName) {
		return null;
	}
	
}
